package se.djupfeldt.oscar.logbook.console.commands;

import se.djupfeldt.oscar.logbook.console.ConsoleHandler;

public class Help extends Command {
    
    private static Help instance;
    
    public static Help getInstance() {
	if (instance == null)
	    instance = new Help();
	return instance;
    }

    @Override
    public String execute(String[] args) {
	if (args.length > 1)
	    return "Too many arguments.";
	else if (args.length == 0)
	    return help();
	else
	    return ConsoleHandler.getInstance().getCommands().get(args[0]).help();
    }

    public String help() {
	String ret = "Help\nhelp <command>\nAvailable commands:";
	for (String cmd : ConsoleHandler.getInstance().getCommands().keySet()) {
	    ret += "\n" + cmd;
	}
	
	return ret;
    }
}
